package com.security.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @author cici
 */
@FeignClient(name = "wechat",url = "https://api.weixin.qq.com")
public interface WeChatServiceFeign {

    /**
     * 根据code 获取用户微信openid 和session
     * @param appId
     * @param secret
     * @param code
     * @param grantType
     * @return
     */
    @RequestMapping(value = "/sns/jscode2session",method = RequestMethod.GET)
    public String jscode2session(@RequestParam(value = "appid") String appId, @RequestParam(value = "secret") String secret, @RequestParam(value = "js_code") String code, @RequestParam(value = "grant_type") String grantType);

    /**
     * 获取小程序 access_token
     * @param appId  AppID
     * @param secret AppSecret
     * @param grantType 默认是client_credential
     * @return
     */
    @RequestMapping(value = "/cgi-bin/token",method = RequestMethod.GET)
    public Map getWeChatAppToken(@RequestParam(value = "appid") String appId, @RequestParam(value = "secret") String secret, @RequestParam(value = "grant_type") String grantType);

}
